<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* .box{ */
            /* width: 500px; */
            /* height: 500px; */
        /* } */
        .my-enter{
            opacity: 0;
            height: 0;
            animation-delay: 1s;
        }
        .my-enter-active{
            transition: all 1s;
        }
        .my-enter-to{
            opacity: 1;
            /* height: 500px; */
        }
        .my-leave{
            opacity: 1;
            /* height: 500px; */
        }
        .my-leave-active{
            transition: all 1s;
        }
        .my-leave-to{
            opacity: 0;
            /* height: 0; */
        }
    </style>
</head>
<body>
    <div id="app">
       <transition name="my" mode="out-in">
            <!-- <img class="box" v-if="juage" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp09%2F21061109241GT3-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656467413&t=bcf730a1a7a823317039429925aae7d2" alt=""> -->
            <div :is="com" style="margin-bottom:20px ;"></div>
       </transition>
       <button @click="show" >点击隐藏</button>
    </div>
</body>
<template id="ComA">
    <div>我是aaaaa组件</div>
</template>
<template id="ComB">
    <div>我是bbbbb组件</div>
</template>
<script src="../vue.js"></script>
<script>
    let ComA={
        template:"#ComA"
    }
    let ComB={
        template:"#ComB"
    }
    new Vue({
        el:"#app",
        components:{
            ComA,ComB
        },
        data:{
            juage:true,
            com:"com-a"
        },
        methods:{
            show(){
                if(this.com=="com-a"){
                    this.com="com-b"
                }else{
                    this.com="com-a"
                }
            }
        }
    })
</script>
</html>